import 'package:flutter/material.dart';
import 'package:xiongan_app_yy/entrys/rp/car_info_list_entity.dart';
import 'package:xiongan_app_yy/widgets/comm/badge.dart';
import 'package:xiongan_app_yy/widgets/comm/text_exhibition_card_widget.dart';

class CarInfoListShow extends StatelessWidget {
  List<CarInfoListItem> datas=[];

  CarInfoListShow(this.datas);

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      shrinkWrap: true,
      physics: ScrollPhysics(),
      itemBuilder: (context, index) {
        return CarItem(datas[index], index);
      },
      scrollDirection: Axis.vertical,
      itemCount: datas.length,
      padding: EdgeInsets.only(top: 0),
    );
  }
}

class CarItem extends StatelessWidget {
  CarInfoListItem data;
  int index;

  CarItem(this.data, this.index);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(left: 10, right: 10),
      child: Row(
        children: <Widget>[
          Center(
            child: Container(
              width: 24,
              height: 24,
              child: Badge(
                  padding: 6,
                  child: Text(""),
                  backgroundColor: Colors.blue,
                  text: "${index + 1}"),
            ),
          ),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                TextExhibitionCardWidget(
                    distance: EdgeInsets.only(
                        right: 15, left: 15, bottom: 16, top: 16),
                    title: "车牌号码",
                    exhibitionText: data.carno ?? ""),
                TextExhibitionCardWidget(
                    distance: EdgeInsets.only(
                        right: 15, left: 15, bottom: 16, top: 16),
                    title: "司机姓名",
                    exhibitionText: data.driver ?? ""),
                TextExhibitionCardWidget(
                    distance: EdgeInsets.only(
                        right: 15, left: 15, bottom: 16, top: 16),
                    title: "手机号",
                    exhibitionText: data.phone ?? ""),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
